package edu.hwadee.serviceImpl;

import java.util.List;

import edu.hwadee.entity.Companypaperrecord;
import edu.hwadee.service.CompanypaperrecordService;

public class CompanypaperrecordServiceImpl extends BasicServiceImpl implements CompanypaperrecordService {

	@Override
	public boolean save(Companypaperrecord companypaperrecord) {
		try {
			getCompanypaperrecordDAO().save(companypaperrecord);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public boolean delete(Companypaperrecord companypaperrecord) {
		try {
			getCompanypaperrecordDAO().delete(companypaperrecord);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Companypaperrecord> search(Companypaperrecord companypaperrecord) {
		try {
			return (List<Companypaperrecord>)getCompanypaperrecordDAO().findByExample(companypaperrecord);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Companypaperrecord searchById(Integer companypaperrecordId) {
		try {
			return getCompanypaperrecordDAO().findById(companypaperrecordId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public boolean update(Companypaperrecord companypaperrecord) {
		try {
			if(searchById(companypaperrecord.getRecordId()) != null) {
				getCompanypaperrecordDAO().merge(companypaperrecord);
				return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Companypaperrecord> showAll() {
		try {
			return (List<Companypaperrecord>)getCompanypaperrecordDAO().findAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
